package com.sunjob.mroresumeproject.service;

import com.sunjob.common.domain.mroresume.CKParts;
import com.sunjob.common.util.MROUtils;
import com.sunjob.mroresumeproject.dao.CKPartsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class CKPartsServiceImpl implements CKPartsServcie{

    @Autowired
    CKPartsMapper ckPartsMapper;


    //查询部件定检履历的所有记录
    @Override
    public int querycount() {
        return ckPartsMapper.querycount();
    }

    //第一页查询五条部件定检履历记录
    @Override
    public List<CKParts> queryCKparts(int pages, int size) {
        return ckPartsMapper.queryCKparts(pages,size);
    }

    //搜索框条件查询可以是部件定检编号或者部件名称
    @Override
    public List<CKParts> queryCKparts2(String checkid) {

        return ckPartsMapper.queryCKparts2(checkid);


    }


    //部件定检履历记录新增
    @Override
    public void insertCKparts(CKParts ckParts) {
        ckParts.setCheckid(MROUtils.nextId());
        ckParts.setStarttime(LocalDateTime.now());
        ckParts.setEndtime(LocalDateTime.now());
        ckParts.setStatues(1);
        ckPartsMapper.insertCKparts(ckParts);
    }

    //部件定检履历记录新增后查询
    @Override
    public List<CKParts> queryCKparts5() {
        return ckPartsMapper.queryCKparts5();
    }

    //部件定检履历查询根据当前checkid编辑的一条记录
    @Override
    public List<CKParts> queryCKpartsone(Long checkid) {
        return ckPartsMapper.queryCKpartsone(checkid);
    }

    @Override
    public void updateCKparts(String checkid, String CKcontent, String partstypes, String management, String partsinitial, String partsend, String failreason, String money, String starttime, String endtime) {
        ckPartsMapper.updateCKparts(checkid,CKcontent,partstypes,management,partsinitial,partsend,failreason,money,starttime,endtime);
    }

    @Override
    public void deleteCKparts(String checkid) {
        ckPartsMapper.deleteCKparts(checkid);
    }

    @Override
    public void deleteCKpartsone(String s) {
        ckPartsMapper.deleteCKpartsone(s);
    }


}
